<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/pageHead.jsp"%>
<script type="text/javascript">
	function view(val){
		var id = val;
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/jpush/jspushView.web?id="+id
		});
	}
	function query_datagrid(){
		//加载分页控件 datagrid
		$('#datagrid').issdatagrid({
			formid : 'form1',
			title : '<%=MessageResourcesUtils.getMessage(request, "jpush.module.list.title")%>',
			width : 'auto',
			nowrap : true,
			autoRowHeight : false,
			singleSelect : true,
			striped : true,
			url : '${systemctx}/jpush/queryJpushInfoList.json',
			sortName : 'modifytime',
			sortOrder : 'desc',
			remoteSort : true,
			idField : 'id',
			pagination : true,
			rownumbers : true,
			showFooter : true,
			queryParams:$('#form1').serializeObject(),
			frozenColumns :[[
				{field : 'id',hidden:true},
				{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.title")%>',field : 'title',width:320,sortable : true,align : 'left',formatter: function(value,row,index){
						return "<a href=\"javascript:void(0);\" onclick=\"view('"+row.id+"')\">"+value+"</a>";
					}
				}
            ]],
			columns : [[ 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.allperson")%>',field : 'allperson',sortable : true,align : 'left',width:130}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.person")%>',field : 'pushname',sortable : true,align : 'left',width:130}, 
              	{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.acceptperson")%>',field : 'username',sortable : true,align : 'left',width:130}, 
              	
              	{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.storename")%>',field : 'storename',sortable : true,align : 'left',width:160},
              	{title : '<%=MessageResourcesUtils.getMessage(request,"jpush.module.col.inputtime")%>',field : 'inputtime',sortable : true,align : 'left',width:160}
            ]],
			onLoadSuccess : function(data) {

			}
		});
	}

	$(document).ready(function() {
		$("#state").selectutil({
			optModel : <%=SysConstant.CommonApproveStatus.getMode1JSONString(true, false)%>
		});
		query_datagrid();
		$('#butQuery').click(function() {
			$('#datagrid').datagrid('load',$('#form1').serializeObject());
		});

		$('#butRest').click(function() {
			$('#currencynum').val('');
			$('#currencyname').val('');
		});
		
		$("#storename").issNewMagnifier({
			title: '<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.select.title") %>',
			url: '${systemctx}/publicMagnifier/publicMagnifier.json',
			sortName: 'modifytime',
			sortOrder: 'desc',
			linkName: 'number',
			callSqlKey: 'queryStoreMagnifierSql',
			changeIgnore:['storename'],
			columns: [[
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.number") %>',field:'number',width:180,sortable:true,search:true,align:'left'},
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.name") %>',field:'name',width:180,search:true,sortable:true,align:'left',formel:'storename'},
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.corporate") %>',field:'corporate',width:180,search:true,sortable:true,align:'left'},
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.email") %>',field:'email',width:180,search:true,sortable:true,align:'left'},
					{title:'<%=MessageResourcesUtils.getMessage(request, "dailyoperation.store.column.telephonenumber") %>',field:'telephonenumber',width:180,search:true,sortable:true,align:'left'},
					{field:'id', hidden:true, formel:'storeId'}
			]],
			onBeforeVaild:function(p){
				if($('#storename').val() == '' || $('#storename').val() == null){
					$('#storename').val('${storename}');
				}
			},
			onBeforeOpen:function(p){
		      	var queryParams = {
		      		  name: $('#storename').val(),
		      		  state: <%=SysConstant.CommonApproveStatus.OK %>,
		    		  statusid: <%=SysConstant.RecordStatus.VALID %>,
		    		  businessstatus:<%=SysConstant.CommonUsedStatus.START %>
		      	};
		      	return queryParams; 
		    }
		});

	});
	
	function addStoreInfo(){
		$(this).isswindow({
			noheader : true,
			url :"${systemctx}/jpush/jspushAdd.web"
		});
	}
	function deleteInfo(id){
		var ids = id;
		if (ids != '' && ids != undefined) {
			var statu = confirm("<%=MessageResourcesUtils.getMessage(request, "common.message.alert")%>");
		    if(!statu){
		        return false;
		    }else {
		    	// 显示进度条
				showSending();
				$.ajax({
					type: 'POST',
				    url: '${systemctx}/dailyoperation/store/delete.web?ids='+ids,
				    data: $("#form1").serialize(),
				    dataType: 'json',
				    success: function(data) {
				    	//关闭执行...
						closeSending();
				    	if(data.code == 200){
				    		alert("<%=MessageResourcesUtils.getMessage(request, "common.alert.success")%>");
				    		<%-- messageAlert("<%=MessageResourcesUtils.getMessage(request, "common.alert.success")%>"); --%>
				    		query_datagrid();
				    	}else {
				    		messageAlert(data.message);
				    	}
				    }
				});
		    }
		}
	}
	function editInfo(flag){
		var ids = flag;
		if (ids != '' && ids != undefined) {
			$(this).isswindow({
				noheader : true,
				url :"${systemctx}/dailyoperation/store/storeEdit.web?id="+ids
			});
		}
	}
	
	function getIds(flag) {
		var ids = "";
		var rows = $('#datagrid').datagrid('getChecked');
		if (rows.length == 0) {
			messageAlert("<%=MessageResourcesUtils.getMessage(request, "dailyoperation.selects.warning")%>");
			return;
		} else {
			if (flag == 1) {
				if (rows.length > 1) {
					messageAlert("<%=MessageResourcesUtils.getMessage(request, "dailyoperation.selects.edit.warning")%>");
					return;
				} else {
					ids = rows[0].id;
					return ids;
				}
			} else {
				for (var i = 0; i < rows.length; i++) {
					ids += rows[i].id + ",";
				}
				if (ids != '') {
					ids = ids.substring(0,ids.length - 1);
				}
				return ids;
			}
		}
	}
	
</script>

<form name="form1" id="form1">
	<div class="pageMain">
		<div class="pageTitle">
			<%=MessageResourcesUtils.getMessage(request, "systemmanage.contentmanagement.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "jpush.module.title") %>
			<span></span>
			<%=MessageResourcesUtils.getMessage(request, "jpush.module.list.title") %>
		</div>
		<div class="pageBody">
			<div class="form-group">
				<ul>
					<li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.name") %>
						</label>
						<span>
							<input type="text" name="storename" id="storename">
							<input type="hidden" name="storeid" id="storeId">
						</span>
					</li>
					<%-- <li>
						<i></i>
						<label>
							<%=MessageResourcesUtils.getMessage(request,"dailyoperation.store.column.state") %>:
						</label>
						<span><select name="state" id="state"></select></span>
					</li> --%>
				</ul>
			</div>	
		</div>
		<div class="button-group">
			<input type="button" class="btn btn-default" id="butQuery"  value="<%=MessageResourcesUtils.getMessage(request,"common.button.query") %>" />
			<input type="button" class="btn btn-default" onclick="addStoreInfo()" value="<%=MessageResourcesUtils.getMessage(request,"common.button.add") %>" />
		</div>
		<table width="100%">
			<tbody>
				<tr>
					<td>
						<table id="datagrid"></table>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</form>

<%-- 引入页面尾 --%>
<%@ include file="/pageFloor.jsp"%>